<?php 
class backend_modules_items extends HModule {
	public $page;
	public $data;
	
	function run() {		
		// Validate POSTBACK
		if (isset($_POST['tbxName'])) {
			// Process the add form post
			self::process();
		}
		else {			
			// Get the current table page
			if (!isset($_GET['page'])) $this->page = 1;
			else $this->page = HCommon::xss($_GET['page']);
			
			// get Paged Data
			$this->data = HModulesInstances::getPaged($this->page, PAGE_SIZE, $_GET['id']);
		}
	}
	
	// Process of the form add
	function process() {
		$name = $_POST['tbxName'];		
		if (HModulesInstances::insert($name, $_GET['id']))
			HUtil::alert('Module item added successfully!');
		else 
			HUtil::alert('ERROR! Module item added unsuccessfully!');
		HUtil::redirect(HCommon::navigateUrl('ModulesItems',array('id'=>$_GET['id'])));
	}
}

?>